package com.yingside.guess;

import java.util.Scanner;
public class Game {

    Scanner input = new Scanner(System.in);

    public void startGame(){
        Person p = new Person();
        Computer c = new Computer();

        //输入人的名字
        System.out.println("请输入你的名字:");
        p.username = input.next();


        //输入电脑的名字
        System.out.println("请选择电脑人物：1.七代火影鸣人 2.超级赛亚人悟空 3.海贼王路飞");
        int choose = input.nextInt();

        switch(choose){
            case 1:
                c.computerName = "七代火影鸣人";
                System.out.println("电脑选择人物:" + c.computerName);

                break;
            case 2:
                c.computerName = "超级赛亚人悟空";
                System.out.println("电脑选择人物:" + c.computerName);

                break;
            case 3:
                c.computerName = "海贼王路飞";
                System.out.println("电脑选择人物:" + c.computerName);
                break;
        }


        //比较
        //人赢的情况
        String answer = "y";
        int userCount = 0;
        int computerCount = 0;
        int draw = 0;

        while(true){
            //获取人出拳
            int userFist = p.showUserFist();
            //获取电脑出拳
            int computerFist = c.showComputerFist();

            if((userFist == 1 && computerFist ==3) ||
                    (userFist == 2 && computerFist ==1) ||
                    (userFist == 3 && computerFist ==2) ){
                System.out.println(p.username + "，真厉害，你赢了，么么哒");
                userCount ++;
            }
            else if((userFist == 1 && computerFist == 2) ||
                    (userFist == 2 && computerFist == 3) ||
                    (userFist == 3 && computerFist == 1)){
                System.out.println(p.username + "，笨蛋，你输了~~");
                computerCount ++;
            }
            else{
                System.out.println("平了~~~");
                draw ++;
            }


            System.out.println("请问你要继续游戏吗？(y/n)");
            answer = input.next();

            if(answer.equalsIgnoreCase("n")){
                break;
            }
        }

        System.out.println("游戏结束~~");
        System.out.println("一共游戏了"+(userCount + computerCount + draw)+"盘，你赢了"+userCount+"盘，你输入了"+computerCount+"盘，平了"+draw+"盘");

    }
}
